#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <locale>
#include <map>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>


#include "debug_macro.h"
#include "speechFunctions.h"


using namespace std;
using namespace boost;
#define MAX_STR_LENGTH  1024

/*some default information about speech file*/
static std::string kaldi_text_scp = "";
static std::string kaldi_wave_scp = "";
static int parelleltaskNo = 1;




int ParseOpt(int argc, char* argv[], Options& options_)
{
	const char * help_information = "--scp-in, wave scp in (in Kaldi scp format)\r\n \
		--text-in, kaldi text in (in Kaldi text format)\r\n \
		--train-ratio, float, less than 1\r\n \
		--test-ratio, float, less than 1\r\n \
		--cv-ratio, float, less than 1\r\n \
		(--train-ratio + --test-ratio + --cv-ratio) should be less than or equal to 1, \r\n \
		-h or --help, print this information.\r\n \
		any questions, please email to : gaoxinglong9999@sina.cn, :) \r\n";
	if( (argc < 2) || (strcmp(argv[1],"-h") == 0)  || ! strcmp(argv[1], "--help") )
	{
		printf("%s\n",help_information);
		return -1;
	}
	
	options_.registration_options("--text-in");

	
	for (int i = 1;i <argc;++i)
	{
		if (! strcmp(argv[i], "--scp-in"))
		{
			options_.add_options("--scp-in", argv[++i]);
			kaldi_wave_scp = argv[i];
		}
		if (! strcmp(argv[i], "--text-in"))
		{
			options_.add_options("--text-in", argv[++i]);
			kaldi_text_scp = argv[i];
		}
		if (! strcmp(argv[i], "--train-ratio"))
		{
			options_.add_options("--train-ratio", argv[++i]);
		}
		if (! strcmp(argv[i], "--test-ratio"))
		{
			options_.add_options("--test-ratio", argv[++i]);
		}
		if (! strcmp(argv[i], "--cv-ratio"))
		{
			options_.add_options("--cv-ratio", argv[++i]);
		}

		if( ! strcmp(argv[i], "--thread-no") ){
			options_.add_options("--thread-no", argv[++i]);
		}
	}
}
//end of Parseopt


int main(int argc, char* argv[])
{
	Options po_;
	if( ParseOpt(argc, argv, po_)<0 )
	{
		return -1;
	}
	ProcessTimitTextTrans(po_);
	return 0;
}
